package com.my.study.redisson.register.listener;

import com.my.study.redisson.register.Message;
import com.my.study.redisson.register.RegisterContext;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.listener.MessageListener;

import javax.annotation.Resource;

/**
 * @author: yidujun
 * @create: 2021/11/23 14:57
 */
@Slf4j
public class CustomMessageListener implements MessageListener<Message> {

    @Resource
    private RegisterContext registerContext;

    /**
     * 处理订阅的消息
     *
     * @param channel 主题
     * @param msg 消息
     */
    @Override
    public void onMessage(CharSequence channel, Message msg) {
        if (channel == null || channel.length() <= 0) {
            return;
        }
        String topic = channel.toString();
        log.info(">>> [onMessage] topic: {}", topic);

        log.info(">>> [onMessage] registerContext: {}", registerContext);
    }
}
